package unit3;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 引例
 */
public class GuidanceExample {
    public static void main(String[] args) {
        System.out.println("请输入大数据竞赛成绩：");
        Scanner in = new Scanner(System.in);
        int[] scores = new int[10]; //定义数组保存10组的竞赛成绩
        // 输入竞赛成绩
        for (int i = 0; i < scores.length; i++) {
            scores[i] = in.nextInt();
        }

        // 统计各组数目
        int countA = 0, countB = 0, countC = 0, countD = 0, countE = 0;
        for (int score : scores) {
            if (score >= 90) {
                countA++;
            } else if (score >= 80) {
                countB++;
            } else if (score >= 70) {
                countC++;
            } else if (score >= 60) {
                countD++;
            } else {
                countE++;
            }
        }
        System.out.println("A:" + countA + "\tB:" + countB + "\tC:" + countC + "\tD:" + countD + "\tE:" + countE);

        // 降序排列
        for (int i = 0; i < scores.length - 1; i++) {
            for (int j = 0; j < scores.length - 1 - i; j++) {
                if (scores[j] < scores[j + 1]) {// 交换数据
                    int temp = scores[j];
                    scores[j] = scores[j + 1];
                    scores[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(scores));
    }
}
